package com.yootk.action;

import com.yootk.service.IMemberService;
import com.yootk.vo.Member;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.Set;

@Slf4j
@RestController
@RequestMapping("/member/*")
public class MemberAction {

    @Autowired
    private IMemberService memberService;

    @RequestMapping("list")
    public Object list() {
        log.info("查询用户列表");
        return memberService.list();
    }

    @RequestMapping("get")
    public Object get(String mid) {
        log.info("查询用户信息：{}", mid);
        return memberService.get(mid);
    }

    @RequestMapping("add")
    public Object add(Member member) {
        log.info("新增用户：{}", member);
        return memberService.add(member);
    }

    @RequestMapping("delete")
    public Object delete(String... mid) {
        log.info("删除用户：{}", Arrays.toString(mid));
        Set<String> ids = Set.of(mid);
        return memberService.delete(ids);
    }

    @RequestMapping("split")
    public Object split(String column, String keyword, Integer currentPage, Integer lineSize) {
        log.info("分页查询用户：column={}、keyword={}、currentPage={}、lineSize={}", column, keyword, currentPage, lineSize);
        return memberService.listSplit(column, keyword, currentPage, lineSize);
    }
}
